package com.atguigu.algorithm;

import java.util.Arrays;

public class NeitherLandProblemPlus {
    public static void main(String[] args) {
        int[] a=new int[]{3,5,6,7,4,3,5,8};
        System.out.println(Arrays.toString(a));
        smallBig(a,5);
        System.out.println(Arrays.toString(a));
    }
    public static void smallBig(int[] a,int num){
        int left=-1;
        int right=a.length;
        for(int i=0;i<right;){
            if(a[i]<num){
                swap(a,left+1,i);
                left++;
                i++;
            }else if(a[i]==num){
                i++;
            }else{
                swap(a,right-1,i);
                right--;
            }
        }
    }
    public static void swap(int[] a,int i,int j){
        int tmp=a[i];
        a[i]=a[j];
        a[j]=tmp;
    }
}
